<?php

class ome_goods_product{
    

    public function checkProductByBn($bn){

        $basicMaterialObj = app::get('material')->model('basic_material');
        $productInfo = $basicMaterialObj->dump(array('material_bn'=>$bn),"bm_id");


        if(!$productInfo){
            return false;
        }

        return $productInfo['bm_id'];
    }
    

    public function getProductByBn($bn){
        $basicMaterialSelect    = kernel::single('material_basic_select');

        $productInfo = $basicMaterialSelect->dump('bm_id, material_bn, material_name', array('material_bn'=>$bn));
        if(!$productInfo){

            return false;

        }
        return $productInfo;

    }
    

    //验证正数(包括小数)

    function valiPositive($data = null){
        if(is_numeric( $data)){
            $new = explode('.',$data);
            $count = count($new);

            if(1 == $count){
                $patter = '/^[1-9]{1}[0-9]{0,}$/';
                preg_match($patter,$new[0],$arr);
                if(empty($arr)){
                    return false;
                }
            }elseif(2 == $count){
                $patter = '/^(?:(?:[0-9]{1})||(?:[1-9]{1}[0-9]{1,}))$/';
                preg_match($patter,$new[0],$arr);
                if(empty($arr)){
                    return false;
                }
            }

            if($data<=0){
                return false;
            }
            return true;
        }else{
            return false;
        }
    }

    //校验字符是否合法
    function validstr($bn){
        preg_match('/\+|\'/',$bn,$filtcontent);
        if ($filtcontent){
            return false;
        }
        return true;
    }

}
